package apis.amapv2.com.io.assets;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import apis.amapv2.com.io.R;

public class AssetsMainActivity extends AppCompatActivity {

    private Context mContext;
    private ListView mLvAssets;
    private List<String> mData = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_assets_main);

        initParamsAndValus();

        initView();
    }

    private void initParamsAndValus() {
        mContext = this;

        mData.add("读取Assets中的xml数据");
    }

    private void initView() {
        mLvAssets = findViewById(R.id.lv_assets);
        mLvAssets.setAdapter(new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, mData));
        mLvAssets.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {//读取Assets中的Xml数据
                    startActivity(new Intent(mContext,AssetsTest1Activity.class));
                }
            }
        });
    }
}
